package com.yikome.order.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.yikome.common.CommonRepository;
import com.yikome.order.entity.OrderProduct;

@Repository
public interface OrderProductRepository extends CommonRepository<OrderProduct, Long> {

	@Query("select t from OrderProduct t where t.yn = 1 and t.id = :orderProductId")
	OrderProduct findOrderProduct(@Param("orderProductId")Long orderProductId);
	
	@Query("select t from OrderProduct t where t.yn = 1 and t.orderCode = :orderCode")
	List<OrderProduct> findOrderProduct(@Param("orderCode")String orderCode);
	
	@Query("select t from OrderProduct t where t.yn = 1 and t.orderCode = :orderCode and t.productSkuBarcode = :productSkuBarcode")
	OrderProduct findOrderProduct(@Param("orderCode")String orderCode , @Param("productSkuBarcode")String productSkuBarcode);
	
	@Query("select t from OrderProduct t where t.yn = 1 and t.productSkuBarcode = :productSkuBarcode")
	List<OrderProduct> findOrderProductWithBarcode(@Param("productSkuBarcode")String productSkuBarcode);
	
	@Query("select t from OrderProduct t where t.yn = 1 and t.productId = :productId")
	List<OrderProduct> findOrderProductWithProductId(@Param("productId")Long productId);

}
